from flask import Flask
from flask_migrate import Migrate, MigrateCommand
from flask_mongoengine import MongoEngine
from flask_script import Manager
from flask_session import Session

# from info.config import REDIS_HOST, REDIS_PORT
from modules import db

app = Flask(__name__)

# 引入配置文件
app.config.from_pyfile("./config.py")

# sql
db.init_app(app)
# 使用 redis存储的 的对象

# 初始化session对象
Session(app)


# 添加数据库迁移等工具
manager = Manager(app)
# 生成migrate对象 用来数据库迁移
migrate = Migrate(app, db)
# 添加db命令
manager.add_command('db', MigrateCommand)


# mongodb 数据库
mdb = MongoEngine(app)

# 定义数据库类型


if __name__ == '__main__':
    manager.run()

